//
//  Const.swift
//  SBNewProject
//
//  Created by hlt on 2023/9/11.
//

import UIKit
let KScreenWidth = UIScreen.main.bounds.width
let kScreenHeight = UIScreen.main.bounds.height
let kScreenbounds =  UIScreen.main.bounds

//顶部导航条高度
fileprivate let kNavigationBarHeight = 44.0

//底部导航高度
fileprivate let kTabarHeight = 49.0


fileprivate  let kStatusHeight = isiPhoneXScreen() ? 44.0 : 20.0 //从iOS 14开始，全面屏iPhone的状态栏高度不一定是44了，可能是47、48.....



fileprivate let kSafeBottomHeight = isiPhoneXScreen() ? 34.0 : 0.0



//let kTabarHeight =  isiPhoneXScreen() ? 83.0 : 49.0 // 49+34
//

struct kScene{
    //状态栏高度
    static  var statusHeight:CGFloat{
        get{
            let scene =  UIApplication.shared.connectedScenes.first
            if  let windowscene = scene as? UIWindowScene{
                let statusBarManger = windowscene.statusBarManager
                
                guard let height = statusBarManger?.statusBarFrame.height else { return  kStatusHeight}
                
                return height
            }else{
                return  kStatusHeight
            }
            
        }
    }
      
    //导航栏高度: 导航条 + 状态栏
    static var navagationHeight:CGFloat{
        get{
       
            return Self.statusHeight + 44.0
        }
    
    }
    
    
    static  var safeBottomHeight:CGFloat{
        get{
            if #available(iOS 13.0, *) {
                let scene =  UIApplication.shared.connectedScenes.first
                if  let windowscene = scene as? UIWindowScene{
                    if let window = windowscene.windows.first{
                        return window.safeAreaInsets.bottom
                    }
                  }
                return  kSafeBottomHeight
                
            }else{
                if let window = UIApplication.shared.delegate?.window{
                    if let insets = window?.safeAreaInsets{
                        return insets.bottom
                    }
                }
               
                return  kSafeBottomHeight
                
             }
        }
    }
    
    //
    static var tabarHeight:CGFloat{
        get{
       
            return Self.safeBottomHeight + kTabarHeight
        }
    
    }
}


struct UserDefaultsKey{
    static let agreeKey = "agreePrivacy"
    
    
}


